package cn.online.service;

import java.util.List;

import cn.online.dao.StudentDao;
import cn.online.model.Student;

public class StudentService {
	
	private StudentDao studentDao;

	public void setStudentDao(StudentDao studentDao) {
		this.studentDao = studentDao;
	}
	
	public void insert(Student student){
		studentDao.save(student);
	}
	
	public void deleteStudents(Integer ids[]){
		Student student=null;
		for(int id:ids){
			student=studentDao.findById(id);
			if(student!=null){
				studentDao.delete(student);
			}
		}
	}
	
	public void updateStudent(Student student){
		studentDao.update(student);
	}
	
	public List<Student> getStudentList(){
		return studentDao.findAll();
	}
	
	public Student findById(Integer id){
		return studentDao.findById(id);
	}
	
	public Student login(String username,String password){
		return studentDao.get(username, password);
	}
	public Student findByName(String username){
		return studentDao.get(username);
	}
}
